import {
    Column,
    Entity,
    JoinColumn,
    ManyToOne,
    PrimaryGeneratedColumn,
} from 'typeorm'
import { Department } from './Department'

@Entity()
export class Employee {
    @PrimaryGeneratedColumn()
    id: number

    @Column({
        length: 50,
    })
    name: string

    // 一对多无需指定外键列, 但可修改外键列名, 不指定则默认主表+id
    // @JoinColumn({
    //     name: 'd_id'
    // })
    @ManyToOne(() => Department, {
        cascade: true,
        onDelete: 'CASCADE',
        onUpdate: 'CASCADE',
    })
    department: Department
}
